<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //Promise构造函数: Promise (excutor) {}
        // (1) executor函数:  执行器  (resolve, reject) => { } 
        // (2) resolve函数: 内部定义成功时我们调用的函数 value => { }
        // (3) reject函数: 内部定义失败时我们调用的函数 reason => { }
        console.log("start....");
        const p = new Promise((resolve, reject) => { 
            console.log("aaaaaaaaa");
            setTimeout(()=>{
                console.log("exec....");
                resolve();
            },3000);
            
            // 在执行器中resolve, reject两个回调函数指定调用一个，并且只能调用一次
            //resolve();
            //resolve();
            //reject();
            //resolve();
           
        });
        console.log("ned....");


        p.then(value => { 
            console.log("成功！");
        }, reason => { 
            console.log("失败！");
        });
    </script>
</body>
</html>